function UpdateRegionDatabase()
%UPDATEREGIONS
%   UpdateRegionDatabase();

global Database;
try
    cw = GetElectrodesBySubject('CW');
    dj = GetElectrodesBySubject('DJ');
    ds = GetElectrodesBySubject('DS');
    fg = GetElectrodesBySubject('FG');
    jf = GetElectrodesBySubject('JF');
    rv = GetElectrodesBySubject('RV');
catch
    error('Create the subjects database before updating regions!');
end

disp('Updating regions...');

Database.regions_header = {'Region', 'CW', 'DJ', 'DS', 'FG', 'JF', 'RV'};
Database.regions = { ...

    'PARAs',     {cw.P12, cw.P13}, ...
                 {}, ...
                 {ds.P44, ds.P36}, ...
                 {},  ...
                 {jf.P09, jf.P11},  ...
                 {rv.C17, rv.C09, rv.C26}; ...
    'PARAi',     {cw.P14, cw.P15, cw.T02}, ...
                 {}, ...
                 {ds.P45, ds.P46, ds.P47, ds.P37, ds.P38, ds.P39}, ...
                 {},  ...
                 {jf.P10, jf.P12, jf.TO39, jf.TO40, jf.TO46, jf.TO47, jf.TO48},  ...
                 {rv.C25, rv.C41, rv.C42, rv.C49, rv.C50, rv.C51, rv.C58, rv.C59}; ...
    'PARA',      {cw.P14, cw.P15, cw.T02, cw.P13, cw.P12}, ...
                 {}, ...
                 {ds.P44, ds.P36, ds.P45, ds.P46, ds.P47, ds.P37, ds.P38, ds.P39}, ...
                 {},  ...
                 {jf.P09, jf.P10, jf.P11, jf.P12, jf.TO46, jf.TO47, jf.TO48, jf.TO39, jf.TO40},  ...
                 {rv.C17, rv.C09, rv.C26, rv.C25, rv.C41, rv.C42, rv.C49, rv.C50, rv.C51, rv.C58, rv.C59}; ...
    'PARAsjf',   {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P09, jf.P11},  ...
                 {}; ...
    'PARs',      {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P03, jf.P05, jf.P07},  ...
                 {}; ...
    'PARPs',      {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P01, jf.P02},  ...
                 {}; ...
    'PARAijf',   {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P10, jf.P12, jf.TO46, jf.TO47, jf.TO48, jf.TO39, jf.TO40},  ...
                 {}; ...
    'PARi',      {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P06, jf.P08, jf.TO38, jf.TO37, jf.TO36, jf.TO45, jf.TO44},  ...
                 {}; ...
    'PARPi',     {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P04, jf.TO42, jf.TO43, jf.TO34, jf.TO35},  ...
                 {}; ...
    'PARAjf',    {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P09, jf.P10, jf.P11, jf.P12, jf.TO46, jf.TO47, jf.TO48, jf.TO39, jf.TO40},  ...
                 {}; ...
    'PAR',       {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P03, jf.P05, jf.P06, jf.P07, jf.P08, jf.TO38, jf.TO37, jf.TO36, jf.TO45, jf.TO44},  ...
                 {}; ...
    'PARP',      {}, ...
                 {}, ...
                 {}, ...
                 {},  ...
                 {jf.P01, jf.P02, jf.P04, jf.TO42, jf.TO43, jf.TO34, jf.TO35},  ...
                 {}; ...
    'OCC',       {cw.Oc10, cw.Oc11, cw.Oc12, cw.OcO2, cw.OcO3, cw.OcO4}, ...
                 {}, ...
                 {ds.Oc49, ds.Oc50, ds.Oc57, ds.Oc58, ds.Oc59, ds.Oc51, ds.Oc52, ds.Oc60, ds.Oc61}, ...
                 {}, ...
                 {jf.TO1, jf.TO9, jf.TO2, jf.TO3, jf.TO10, jf.TO17, jf.TO18, jf.TO25, jf.TO26, jf.TO33, jf.TO41}, ...
                 {}; ...
    'OCCTEM',    {cw.T09, cw.T17, cw.T25, cw.Oc13, cw.OcO5}, ...
                 {}, ...
                 {ds.Oc53, ds.Oc54, ds.Oc55, ds.Oc62, ds.Oc63}, ...
                 {}, ...
                 {jf.TO27, jf.TO28, jf.TO29, jf.TO4, jf.TO5}, ...
                 {}; ...
    'TEM',       {cw.T10, cw.T18, cw.T19, cw.T20, cw.T21, cw.T27, cw.T28}, ...
                 {}, ...
                 {ds.T23, ds.T24, ds.T15, ds.T16, ds.Oc56, ds.P48}, ...
                 {}, ...
                 {jf.TO16, jf.TO24, jf.TO23, jf.TO22, jf.TO31, jf.TO30}, ...
                 {}; ...
   
                 
  % FACEHOUSE plots:                
%     'CW_sTa1',   {cw.sTa1},       {},        {},        {}, {},   {}       ; ...
%     'CW_sTa4',   {cw.sTa4},       {},        {},        {}, {},   {}       ; ...
%     'CW_sTa5',   {cw.sTa5},       {},        {},        {}, {},   {}       ; ...
%     'CW_sTa6',   {cw.sTa6},       {},        {},        {}, {},   {}       ; ...
%     'CW_sTv3',   {cw.sTv3},       {},        {},        {}, {},   {}       ; ...
%     'CW_aT1',    {cw.aT1},       {},        {},        {}, {},   {}       ; ...
%     'CW_aT2',    {cw.aT2},       {},        {},        {}, {},   {}       ; ...
%     'CW_aT4',    {cw.aT4},       {},        {},        {}, {},   {}       ; ...
%      'DS_sTv7',   {},       {},        {ds.sTv7},        {}, {},   {}       ; ...
%      'DS_aT1',    {},       {},        {ds.aT1},        {}, {},   {}       ; ...
%      'DS_sTa1',   {},       {},        {ds.sTa1},        {}, {},   {}       ; ...
%      'DS_sTa2',   {},       {},        {ds.sTa2},        {}, {},   {}       ; ...
%      'DS_sTa5',   {},       {},        {ds.sTa5},        {}, {},   {}       ; ...
%      'DS_sTa6',   {},       {},        {ds.sTa6},        {}, {},   {}       ; ...
%      'DS_T18',     {},       {},        {ds.T18},        {}, {},   {}       ; ...
%      'RV_T03',     {},       {},        {},        {}, {},   {rv.T03}       ; ...
%      'RV_T06',     {},       {},        {},        {}, {},   {rv.T06}       ; ...

  


% junk:    
%     'RVextra1',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {rv.C17, rv.C01, rv.C09, rv.C26}; ...
%     'RVextra2',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {rv.C17, rv.C09, rv.C26}; ...
%    'RVextra3',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {rv.C25, rv.C41, rv.C42, rv.C49, rv.C50, rv.C51, rv.C57, rv.C58, rv.C59}; ...
%    'RVextra4',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {rv.C25, rv.C41, rv.C42, rv.C49, rv.C50, rv.C51, rv.C58, rv.C59}; ...
%    'RVextra5',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  { rv.C49,  rv.C57, rv.C58}; ...

                 
%    'DSextra1',     {}, ...
%                  {}, ...
%                  {ds.P41,ds.P42,ds.P43,ds.P44, ds.P36}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%    'DSextra2',     {}, ...
%                  {}, ...
%                  {ds.P45,ds.P46,ds.P47,ds.P37, ds.P38, ds.P39}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%    'CWextra1',     {cw.P12, cw.P13}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%     'CWextra2',  {cw.T10, cw.T11, cw.T18, cw.T19, cw.T20, cw.T21, cw.T28}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%     'CWextra3',  {cw.T10, cw.T27, cw.T11, cw.T18, cw.T19, cw.T20, cw.T21, cw.T28}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%     'CWextra4',  {cw.T10, cw.T27, cw.T26, cw.T11, cw.T18, cw.T19, cw.T20, cw.T21, cw.T28}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%      'CWextra5',  {cw.P14, cw.P15, cw.T02}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%       'CWextra6',  {cw.P14, cw.P15, cw.T02, cw.T01}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%       'CWextra7',  {cw.T17, cw.T25, cw.Oc13, cw.OcO5, cw.T09}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%        'CWextra8',  {cw.T17, cw.T25, cw.Oc13, cw.OcO5, cw.T09, cw.T18, cw.T26}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {},  ...
%                  {}; ...
%     'JFextra1',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.P01, jf.P02, jf.P03, jf.P04, jf.TO33, jf.TO34, jf.TO41, jf.TO42},  ...
%                  {}; ...
%     'JFextra2',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.P05, jf.P06, jf.P07, jf.P08, jf.TO35, jf.TO36, jf.TO43, jf.TO44},  ...
%                  {}; ...
%     'JFextra3',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.P09, jf.P10, jf.P11, jf.P12, jf.TO37, jf.TO38, jf.TO45, jf.TO46},  ...
%                  {}; ...
%     'JFextra4',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.TO39, jf.TO40, jf.TO47, jf.TO48},  ...
%                  {}; ...
%     'JFextra5',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.TO33, jf.TO34, jf.TO41, jf.TO42},  ...
%                  {}; ...
%     'JFextra6',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.TO35, jf.TO36, jf.TO43, jf.TO44},  ...
%                  {}; ...
%     'JFextra7',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.TO37, jf.TO38, jf.TO45, jf.TO46},  ...
%                  {}; ...
%     'JFextra8',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.P01, jf.P02, jf.P04, jf.TO35, jf.TO34, jf.TO43, jf.TO42},  ...
%                  {}; ...
%     'JFextra9',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.P05, jf.P03,jf.P06, jf.P07, jf.P08, jf.TO37, jf.TO36, jf.TO45, jf.TO44},  ...
%                  {}; ...
%     'JFextra10',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.P09, jf.P10, jf.P11, jf.P12, jf.TO39, jf.TO38, jf.TO47, jf.TO46, jf.TO40},  ...
%                  {}; ...
%     'JFextra11',  {}, ...
%                  {}, ...
%                  {}, ...
%                  {},  ...
%                  {jf.P10, jf.P12, jf.TO39, jf.TO40, jf.TO46, jf.TO47, jf.TO48},  ...
%                  {}; ...
            
%      'RV_C25',     {},       {},        {},        {}, {},   {rv.C25}       ; ...
%      'RV_C41',     {},       {},        {},        {}, {},   {rv.C41}       ; ...
%      'RV_C42',     {},       {},        {},        {}, {},   {rv.C42}       ; ...
%      'RV_C51',     {},       {},        {},        {}, {},   {rv.C51}       ; ...
%      'RV_C58',     {},       {},        {},        {}, {},   {rv.C58}       ; ...
%      'RV_C49',     {},       {},        {},        {}, {},   {rv.C49}       ; ...
%      'RV_C57',     {},       {},        {},        {}, {},   {rv.C57}       ; ...
%      'RV_C59',     {},       {},        {},        {}, {},   {rv.C59}       ; ...
%     'JF_TO46',   {},       {},        {},        {}, {jf.TO46},   {}       ; ...
%     'JF_TO41',   {},       {},        {},        {}, {jf.TO41},   {}       ; ...
%     'JF_TO48',   {},       {},        {},        {}, {jf.TO48},   {}       ; ...
%     'JF_P01',   {},       {},        {},        {}, {jf.P01},   {}       ; ...
%     'JF_P02',   {},       {},        {},        {}, {jf.P02},   {}       ; ...
%     'JF_P03',   {},       {},        {},        {}, {jf.P03},   {}       ; ...
%     'JF_P04',   {},       {},        {},        {}, {jf.P04},   {}       ; ...
%     'JF_P05',   {},       {},        {},        {}, {jf.P05},   {}       ; ...
%     'JF_P06',   {},       {},        {},        {}, {jf.P06},   {}       ; ...
%     'JF_P07',   {},       {},        {},        {}, {jf.P07},   {}       ; ...
%     'JF_P08',   {},       {},        {},        {}, {jf.P08},   {}       ; ...
%     'JF_P13',   {},       {},        {},        {}, {jf.P13},   {}       ; ...
%     'JF_P14',   {},       {},        {},        {}, {jf.P14},   {}       ; ...
%     'JF_P15',   {},       {},        {},        {}, {jf.P15},   {}       ; ...
%     'JF_P16',   {},       {},        {},        {}, {jf.P16},   {}       ; ...
%     'CW_T01',   {cw.T01},       {},        {},        {}, {},   {}       ; ...
%     'CW_T02',   {cw.T02},       {},        {},        {}, {},   {}       ; ...
%     'CW_T03',   {cw.T03},       {},        {},        {}, {},   {}       ; ...
%     'CW_T04',   {cw.T04},       {},        {},        {}, {},   {}       ; ...
%     'CW_T05',   {cw.T05},       {},        {},        {}, {},   {}       ; ...
%     'CW_P07',   {cw.P07},       {},        {},        {}, {},   {}       ; ...
%     'CW_P15',   {cw.P15},       {},        {},        {}, {},   {}       ; ...
%     'DS_Oc62',   {},       {},        {ds.Oc62},        {}, {},   {}       ; ...
%     'DS_Oc63',   {},       {},        {ds.Oc63},        {}, {},   {}       ; ...
%     'DS_Oc64',   {},       {},        {ds.Oc64},        {}, {},   {}       ; ...
%     'DS_Oc49',   {},       {},        {ds.Oc49},        {}, {},   {}       ; ...
%      'DS_Oc50',   {},       {},        {ds.Oc50},        {}, {},   {}       ; ...
%      'DS_Oc57',   {},       {},        {ds.Oc57},        {}, {},   {}       ; ...
%      'DS_Oc58',   {},       {},        {ds.Oc58},        {}, {},   {}       ; ...
%      'DS_Oc59',   {},       {},        {ds.Oc59},        {}, {},   {}       ; ...
%      'DS_Oc51',   {},       {},        {ds.Oc51},        {}, {},   {}       ; ...
%      'DS_Oc52',   {},       {},        {ds.Oc52},        {}, {},   {}       ; ...
%      'DS_Oc60',   {},       {},        {ds.Oc60},        {}, {},   {}       ; ...
%      'DS_Oc61',   {},       {},        {ds.Oc61},        {}, {},   {}       ; ...
%      'JF_TO21',   {},       {},        {},        {}, {jf.TO21},   {}       ; ...
%     'JF_TO28',   {},       {},        {},        {}, {jf.TO28},    {}       ; ...
%     'JF_TO29',   {},       {},        {},        {}, {jf.TO29},   {}       ; ...
%     'JF_TO19',   {},       {},        {},        {}, {jf.TO19},   {}
%     'CW_T18',   {cw.T18},       {},        {},        {}, {},   {}       ; ...
%     'CW_T17',   {cw.T17},       {},        {},        {}, {},   {}       ; ...
%     'CW_T20',   {cw.T20},       {},        {},        {}, {},   {}       ; ...
%     'CW_T21',   {cw.T21},       {},        {},        {}, {},   {}       ; ...
%     'DS_T15',   {},       {},        {ds.T15},        {}, {},   {}       ; ...
%     'DS_P41',   {},       {},        {ds.P41},        {}, {},   {}       ; ...
%     'DS_P42',   {},       {},        {ds.P42},        {}, {},   {}       ; ...
%     'DS_P43',   {},       {},        {ds.P43},        {}, {},   {}       ; ...
%     'DS_Oc56',   {},       {},        {ds.Oc56},        {}, {},   {}       ; ...
%     'DS_T23',   {},       {},        {ds.T23},        {}, {},   {}       ; ...
%     'DS_T24',   {},       {},        {ds.T24},        {}, {},   {}       ; ...
%     'DS_T32',   {},       {},        {ds.T32},        {}, {},   {}       ; ...
%     'DS_T18',   {},       {},        {ds.T18},        {}, {},   {}       ; ...
%     'DS_T16',   {},       {},        {ds.T16},        {}, {},   {}       ; ...
%     'DS_T14',   {},       {},        {ds.T14},        {}, {},   {}       ; ...
%     'JF_TO32',   {},       {},        {},        {}, {jf.TO32},   {}       ; ...
    };

end

